<%@ page session="true" import="ca.ansir.analytics.reports.*,java.util.Calendar" %>
<%@ page contentType="text/xml;charset=UTF-8" pageEncoding="UTF-8" %>
<%
    // This is intended as a quick example to demonstrate the use of the
    // JAnalytics class. In a future version of JAnalytics the plan is to
    // include a tab library to hide these details.

    JAnalytics analytics = new JAnalytics();

    try{
        // Be sure the edit this login line
        analytics.login("youraccount@gmail.com", "yourpassword");

        String[] reportIds = analytics.getReportIds();

        Calendar end = Calendar.getInstance();
        Calendar start = Calendar.getInstance();
        start.roll(Calendar.DAY_OF_YEAR, -7);
        String xmlReport = analytics.getReport(reportIds[0],
                ReportTypes.DASHBOARD_REPORT,start,end);
        System.out.println("Report:\n" + xmlReport);
        response.setContentType("text/html;charset=UTF-8");        
%>
        <%= xmlReport %>
    <%
        } catch(JAnalyticsException e){
            session.setAttribute("error", "Please ensure you edit example1.jsp " 
                    + "and use your account name and password. <br/>" 
                    + e.getMessage());
            response.sendRedirect("error.jsp");
        }
    %>
    
